/*
 * Copyright (c) 2009 Nathaniel Houghton <nathan@brainwerk.org>
 *                    Robert Kirchgessner <rkirchge@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for
 * any purpose with or without fee is hereby granted, provided that
 * the above copyright notice and this permission notice appear in all
 * copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
 * OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 *
 */

#ifndef EVENT_HEADER
#define EVENT_HEADER

#include <stdint.h>

#include "mode.h"

#define MAX_EVENTS 15
#define ACTION_ELM 0
#define ACTION_FLASH 1

extern uint8_t live_mode;

struct event {
	uint8_t interval; /*Logging interval for the event */
	uint8_t count;
	uint8_t action; /*What action is to be performed*/

	uint8_t mode;
	uint8_t pid;
} __attribute__((__packed__));

struct timer {
	uint8_t ding;
	uint8_t overflow;
};

void timer_start(void);
void timer_stop(void);
int8_t event_init(struct event *);
int8_t event_add(struct event *);
void events_start(uint32_t);
uint8_t events_end(uint32_t *);
void events(struct mode *);
void elm_event(struct event *, struct mode *);
void handle_event(struct event *, struct mode *);

#endif
